# # """
# # 实现逻辑:
# # 导包
# # 1. 创建类:Driver
# # 2. 创建初始化方法:init
# #     绑定初始化启动参数
# # 3. 创建实例方法
# #     创建driver对象,对外返回driver
# #
# # """
# #
# # # 实现逻辑:
# # # 导包
# # import time
# # from appium import webdriver
# # # 1. 创建类:Driver
# # class Driver:
# #     # 2. 创建初始化方法:init
# #     def __init__(self):
# #         # 绑定初始化启动参数
# #         self.desire_caps = {
# #             # 通过adb devices获取,此处是模拟器所以填写的是ip和port
# #             "deviceName": "127.0.0.1:21503",
# #             # 被测系统决定是Android还是ios
# #             "platformName": "Android",
# #             # 系统版本:通过查看被测的系统的设置确定
# #             "platformVersion": "5.1.1",
# #             # 包名需进入APP安装包路径通过命令查看:aapt dump badging jinritoutiao.apk |findstr package
# #             "appPackage": "com.ss.android.article.news",
# #             # activity名:需进入app安装包路径通过命令查看:aapt dump badging jinritoutiao.apk |findstr activity
# #             "appActivity": "com.ss.android.article.news.activity.MainActivity",
# #             # 在此会话前不要重置应用程序
# #             "noReset": True,
# #             # 解决输入中文的问题,否则不能用sendkeys输入中文
# #             # "unicodeKeyboard": True,
# #             "automationName": "UIAutomator2"
# #         }
# #         print(self.desire_caps)
# #
# #     # 3. 创建实例方法
# #     def startUp(self):
# #         # 创建driver对象,对外返回driver
# #         # 启动app(参数一:appium服务器地址,参数二:启动参数字典)
# #         driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", self.desire_caps)
# #         # 隐式等待
# #         driver.implicitly_wait(10)
# #         # 等待6秒
# #         time.sleep(6)
# #         # 为外界提供driver对象
# #         return driver
# #
# #
# # if __name__ == '__main__':
# #     d = Driver()
# #     driver = d.startUp()
# #     driver.quit()
#
#
# # """
# # 实现逻辑:
# # 导包
# # 1. 创建类:Driver
# # 2. 创建初始化方法:init
# #     绑定初始化启动参数
# # 3. 创建实例方法
# #     创建driver对象,对外返回driver
# #
# # """
#
# # 实现逻辑:
# # 导包
# import time
# from appium import webdriver
# from common.readConfig import ReadConfig
#
# rc = ReadConfig()
#
#
# # 1. 创建类:Driver
# class Driver:
#     # 2. 创建初始化方法:init
#     def __init__(self):
#         # 绑定初始化启动参数
#         self.desire_caps = {
#             # 通过adb devices获取,此处是模拟器所以填写的是ip和port
#             "deviceName": rc.get_config("driver", "deviceName"),
#             # 被测系统决定是Android还是ios
#             "platformName": "Android",
#             # 系统版本:通过查看被测的系统的设置确定
#             "platformVersion": "5.1.1",
#             # 包名需进入APP安装包路径通过命令查看:aapt dump badging jinritoutiao.apk |findstr package
#             "appPackage": "com.ss.android.article.news",
#             # activity名:需进入app安装包路径通过命令查看:aapt dump badging jinritoutiao.apk |findstr activity
#             "appActivity": "com.ss.android.article.news.activity.MainActivity",
#             # 在此会话前不要重置应用程序
#             "noReset": True,
#             # 解决输入中文的问题,否则不能用sendkeys输入中文
#             # "unicodeKeyboard": True,
#             "automationName": "UIAutomator2"
#         }
#         print(self.desire_caps)
#
#     # 3. 创建实例方法
#     def startUp(self):
#         # 创建driver对象,对外返回driver
#         # 启动app(参数一:appium服务器地址,参数二:启动参数字典)
#         driver = webdriver.Remote("http://127.0.0.1:4725/wd/hub", self.desire_caps)
#         # 隐式等待
#         driver.implicitly_wait(10)
#         # 等待6秒
#         time.sleep(6)
#         # 为外界提供driver对象
#         return driver
#
#
# if __name__ == '__main__':
#     d = Driver()
#     driver = d.startUp()
#     driver.quit()


# """
# 实现逻辑:
# 导包
# 1. 创建类:Driver
# 2. 创建初始化方法:init
#     绑定初始化启动参数
# 3. 创建实例方法
#     创建driver对象,对外返回driver
#
# """
#
# # 实现逻辑:
# # 导包
# import time
# from appium import webdriver
# # 1. 创建类:Driver
# class Driver:
#     # 2. 创建初始化方法:init
#     def __init__(self):
#         # 绑定初始化启动参数
#         self.desire_caps = {
#             # 通过adb devices获取,此处是模拟器所以填写的是ip和port
#             "deviceName": "127.0.0.1:21503",
#             # 被测系统决定是Android还是ios
#             "platformName": "Android",
#             # 系统版本:通过查看被测的系统的设置确定
#             "platformVersion": "5.1.1",
#             # 包名需进入APP安装包路径通过命令查看:aapt dump badging jinritoutiao.apk |findstr package
#             "appPackage": "com.ss.android.article.news",
#             # activity名:需进入app安装包路径通过命令查看:aapt dump badging jinritoutiao.apk |findstr activity
#             "appActivity": "com.ss.android.article.news.activity.MainActivity",
#             # 在此会话前不要重置应用程序
#             "noReset": True,
#             # 解决输入中文的问题,否则不能用sendkeys输入中文
#             # "unicodeKeyboard": True,
#             "automationName": "UIAutomator2"
#         }
#         print(self.desire_caps)
#
#     # 3. 创建实例方法
#     def startUp(self):
#         # 创建driver对象,对外返回driver
#         # 启动app(参数一:appium服务器地址,参数二:启动参数字典)
#         driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", self.desire_caps)
#         # 隐式等待
#         driver.implicitly_wait(10)
#         # 等待6秒
#         time.sleep(6)
#         # 为外界提供driver对象
#         return driver
#
#
# if __name__ == '__main__':
#     d = Driver()
#     driver = d.startUp()
#     driver.quit()


# """
# 实现逻辑:
# 导包
# 1. 创建类:Driver
# 2. 创建初始化方法:init
#     绑定初始化启动参数
# 3. 创建实例方法
#     创建driver对象,对外返回driver
#
# """

# 实现逻辑:
# 导包
import time
from appium import webdriver
from common.readConfig import ReadConfig

rc = ReadConfig()


# 1. 创建类:Driver
class Driver:
    # 预设类属性:不同设备连接信息
    devicesName = None
    port = None


    # 2. 创建初始化方法:init
    def __init__(self):





        # 绑定初始化启动参数
        self.desire_caps = {
            # 通过adb devices获取,此处是模拟器所以填写的是ip和port
            "deviceName": self.devicesName,
            # 被测系统决定是Android还是ios
            "platformName": "Android",
            # 系统版本:通过查看被测的系统的设置确定
            "platformVersion": "5.1.1",
            # 包名需进入APP安装包路径通过命令查看:aapt dump badging jinritoutiao.apk |findstr package
            "appPackage": "com.ss.android.article.news",
            # activity名:需进入app安装包路径通过命令查看:aapt dump badging jinritoutiao.apk |findstr activity
            "appActivity": "com.ss.android.article.news.activity.MainActivity",
            # 在此会话前不要重置应用程序
            "noReset": True,
            # 解决输入中文的问题,否则不能用sendkeys输入中文
            # "unicodeKeyboard": True,
            # "automationName": "UIAutomator2",
            # 自动重启app(多设备执行时需添加,单设备不要添加)
            "autoLaunch":False
        }
        print(self.desire_caps)

    # 3. 创建实例方法
    def startUp(self):
        # 创建driver对象,对外返回driver
        # 启动app(参数一:appium服务器地址,参数二:启动参数字典)
        driver = webdriver.Remote("http://127.0.0.1:"+str(self.port)+"/wd/hub", self.desire_caps)
        # 隐式等待
        driver.implicitly_wait(10)
        # 等待6秒
        time.sleep(6)
        # 为外界提供driver对象
        return driver


if __name__ == '__main__':
    Driver.devicesName = "127.0.0.1:21513"
    Driver.port = 4725


    d = Driver()
    driver = d.startUp()
    driver.quit()
